{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
~}}

<div>
  <JobEditor::Alert 
    @data={{merge (hash error=this.error stage=this.stage) this.data}}
    @fns={{this.fns}}
  />

    {{#if (eq @context "new")}}
      <header class="run-job-header">
        <h1 class="title is-3">Run a job</h1>
        <p>
          Paste or author HCL or JSON to submit to your cluster, or select from a list of templates. A plan will be requested before the job is submitted. You can also attach a job spec by uploading a job file or dragging &amp; dropping a file to the editor.
        </p>
        <Hds::ButtonSet>
          <label
            class="job-spec-upload hds-button hds-button--color-secondary hds-button--size-medium"
          >
            <div class="hds-button__text">Upload file</div>
            <input
            type="file"
              onchange={{action this.fns.onUpload}}
              accept=".hcl,.json,.nomad"
            />
          </label>
          {{#if (can "read variable" path="nomad/job-templates/*" namespace="*")}}
            <Hds::Button
              @text="Choose from template"
              @color="secondary"
              @route="jobs.run.templates"
              data-test-choose-template
            />
          {{/if}}
        </Hds::ButtonSet>
      </header>
    {{/if}}
    {{did-update this.setDefinitionOnModel this.definition}}
    {{component (concat 'job-editor/' this.stage) data=this.data fns=this.fns}}
</div>
